from flask_login import UserMixin

class User(UserMixin):
    def __init__(self, user_data):
        self.id = user_data['id']
        self.username = user_data['username']
        self.nickname = user_data['nickname']
        self.email = user_data['email']
        self.phone = user_data['phone']
        self.avatar = user_data['avatar']
        self.status = user_data['status']
        self.password = user_data['password']
        self.is_deleted = user_data['is_deleted']
        self.created_time = user_data['created_time']
        self.update_time = user_data['update_time']
        self.last_login_time = user_data['last_login_time']

    def get_id(self):
        return str(self.id)

    @property
    def is_authenticated(self):
        return True

    @property
    def is_active(self):
        return self.status == 1

    @property
    def is_anonymous(self):
        return False